package com.tanhua.app.controller;


import com.itheima.model.vo.VoiceVo;
import com.tanhua.app.service.VoiceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@RequestMapping("/peachblossom")
public class VoiceController {

    @Autowired
    private VoiceService voiceService;

    //桃花传音发送语音
    @PostMapping
    public ResponseEntity saveVoice(MultipartFile soundFile) throws IOException {
        voiceService.saveVoice(soundFile);
        return ResponseEntity.ok(null);
    }

    //接收语音
    @GetMapping
    public ResponseEntity queryVoiceList() {
        VoiceVo vo = voiceService.queryVoice();
        return ResponseEntity.ok(vo);
    }
}
